package main

import (
	"encoding/json"
	"fmt"
	"strings"
)

//import (
//	"encoding/json"
//	"fmt"
//)
//
//type people struct {
//	Name string `json:"name"`
//	Age  int    `json:"age"`
//	Id   int    `json:"id"`
//}
//
//type student struct {
//	people
//	Id int `json:"sid"`
//}
//
//func main() {
//	msg := "{\"name\":\"zhangsan\", \"age\":18, \"id\":122463, \"sid\":122464}"
//	var someOne student
//	if err := json.Unmarshal([]byte(msg), &someOne); err == nil {
//		fmt.Println(someOne)
//		fmt.Println(someOne.people.Age)
//	} else {
//		fmt.Println(err)
//	}
//}



func main() {

	//b := []byte(`{"IP": "127.0.0.1", "name": "576576567"}`)
	//m := make(map[string]string)
	//err := json.Unmarshal(b, &m)
	//if err != nil {
	//	fmt.Println("Umarshal failed:", err)
	//	return
	//}
	//
	//
	//fmt.Println("m:", m)
	//
	//for k,v :=range m {
	//	fmt.Println(k, ":", v)
	//}

	type userinfo struct {
		Username string `json:"username"`
		Role string `json:"role"`
		Portraiturl string `json:"portraiturl"`
	}
	var someOne userinfo
	if err := json.Unmarshal([]byte(`{"username":"askmeatadmin","role":"superuser","portraiturl":"http://rundeep.f3322.org:19001/static/img/superuser.jpg","exp":1513580645}`), &someOne); err == nil {
		fmt.Println(someOne)
		fmt.Println(someOne.Username)
	} else {
		fmt.Println(err)
	}

	aa := "{\"username\":\"askmeatadmin\",\"role\":\"superuser\",\"portraiturl\":\"http://rundeep.f3322.org:19001/static/img/superuser.jpg\",\"exp\":1513580645}"

	bb := strings.Split(aa,",")
	fmt.Println(bb[0])
    cc := strings.Split(bb[0],":")
    fmt.Println(cc[1])
    dd := strings.Split(cc[1],"\"")
    fmt.Println(dd[1])





}





